import { createApp } from "vue"
import App from "./App.vue"
import router from "./router"

import * as ElementPlus from "element-plus"
import { login } from "./api/user"
import store from "./stores/counter"
import "uno.css"
import "@iconify-json/ep"
import "element-plus/theme-chalk/index.css"
import "../common.less"
// import monaco from "./utils/userWorker"
// 自动导入插件 默认支持使用createPinia
const app = createApp(App)
window._customComponents = {}
import * as ElementPlusIconsVue from "@element-plus/icons-vue"

setTimeout(() => {
  for (const [key, com] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, com)
    window._customComponents[key] = com
  }
  for (const [key, com] of Object.entries(ElementPlus)) {
    app.component(key, com)
    window._customComponents[key] = com
  }
}, 0)
window._app = app

const components = import.meta.glob("./components/*.vue")
Object.entries(components).map(async ([com, module]) => {
  const name = com.match(/\.\/components\/([^/]+?)\.vue/i)?.[1]
  app.component(name, module)
})
import testCom from "@/components/testCom.vue"
import customCollapse from "@/components/customCollapse"
import customPosition from "@/components/customPosition.vue"
import customRegion from "@/components/customRegion"
import test1 from "@/components/test1"
import formCom from "@/components/formCom"
import customInput from "@/components/customInput.vue"
app.component("formCom", formCom)

window._customComponents["testCom"] = testCom
window._customComponents["ElCollapseItem"] = customCollapse
window._customComponents["customCollapse"] = customCollapse
window._customComponents["customRegion"] = customRegion
window._customComponents["customInput"] = customInput
window._customComponents["customPosition"] = customPosition
window._customComponents["formCom"] = formCom
window._customComponents["test1"] = test1
// const jsxcomponents = import.meta.glob("./components/*.tsx")
// Object.entries(jsxcomponents).map(([com, module]) => {
//   const name = com.match(/\.\/components\/([^/]+?)\.tsx/i)?.[1]
//   app.component(name, module)
// })
app.use(ElementPlus).use(router).use(createPinia()).mount("#app") //.use(ElementPlus)
// let num:string=123 // vite 默认只会编译ts 不会检测ts

// eslint 代码 prettier 风格 editconfig 配置
// eslint 插件 prettier 插件 editconfig 插件
// 默认格式化
// 配合 git hook 实现提交代码前 先进行校验

// husky

// commitlint

// login<{ username: string; token: string }>({
//   username: "hello",
//   password: "jw"
// }).then((res) => {
//   console.log(res.data?.username)
// })
